package com.easthome.process.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easthome.auth.service.SysUserService;
import com.easthome.model.process.ProcessRecord;
import com.easthome.model.system.SysUser;
import com.easthome.process.mapper.ProcessRecordMapper;
import com.easthome.process.service.ProcessRecordService;
import com.easthome.security.custom.LoginUserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: 朱敦宇
 * @time: 2023/11/22 18:36
 */
@Service
public class ProcessRecordServiceImpl extends ServiceImpl<ProcessRecordMapper, ProcessRecord> implements ProcessRecordService {
    @Autowired
    private SysUserService sysUserService;
    @Override
    public void record(Long id, int i, String description) {
        ProcessRecord processRecord = new ProcessRecord();
        processRecord.setDescription(description);
        processRecord.setOperateUserId(LoginUserHelper.getUserId().get());
        processRecord.setProcessId(id);
        processRecord.setStatus(i);
        SysUser user = sysUserService.getById(processRecord.getOperateUserId());
        processRecord.setOperateUser(user.getName());
        baseMapper.insert(processRecord);
    }
}
